#include "LoadBalancedEventThreadPool.h"
#include "EventLoopThreadPool.h"
#include "EventLoop.h"

LoadBalanceEventThreadPool::LoadBalanceEventThreadPool(EventLoop *base,
                                                       int numThreads,
                                                       const std::string &name)
  : EventLoopThreadPool(base, numThreads, name)
{}



EventLoop* LoadBalanceEventThreadPool::getNextLoop() 
{
  EventLoop* loop = m_baseLoop;
  for (int i = 0; i < m_loops.size(); i++) {
    if (loop->getlistenCnt() > m_loops[i]->getlistenCnt()) {
      loop = m_loops[i];
    }
  }
  return loop;
}